<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!--[if lt IE 9]>
<script type="text/javascript" src="/static/lib/html5shiv.js"></script>
<script type="text/javascript" src="/static/lib/respond.min.js"></script>
<![endif]-->
<link rel="stylesheet" type="text/css" href="/static/h-ui/css/H-ui.min.css" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/css/H-ui.admin.css" />
<link rel="stylesheet" type="text/css" href="/static/lib/Hui-iconfont/1.0.8/iconfont.css" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/skin/default/skin.css" id="skin" />
<link rel="stylesheet" type="text/css" href="/static/h-ui.admin/css/style.css" />
<script src="/static/lib/vue/vue.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/static/lib/axios/axios.min.js"></script>
<!--[if IE 6]>
<script type="text/javascript" src="/static/lib/DD_belatedPNG_0.0.8a-min.js" ></script>
<script>DD_belatedPNG.fix('*');</script>
<![endif]-->
<title>采集网站列表</title>
<style>
	.addname{width: 150px;height: 31px;display: inline-block;position: relative;}
	.selmsg{position: absolute; display: none; top: 31px; left: 0; background: #f7f7f7; border: 1px solid #e6e3e3; } 
	.selmsg ul li{border-bottom: 1px dashed #d2d0d0;padding: 10px;cursor: pointer;}
	.selmsg ul li:hover{background: #eef4fb;}
</style>
</head>
<body>
<div id="app">
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 首页 <span class="c-gray en">&gt;</span>  采集网站列表 <a class="btn btn-success radius r btn-refresh" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
	{% raw %}
	<div class="text-c">
	<input type="text" v-model="kw" name="kw" id="kw" placeholder="名称" style="width:250px" class="input-text">
	<button name="" id="ser" v-on:click="serch" class="btn btn-success" type="button"><i class="Hui-iconfont">&#xe665;</i> 搜</button>
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<a href="javascript:;" onclick="datadel()" class="btn btn-danger radius"><i class="Hui-iconfont">&#xe6e2;</i> 批量删除</a> 
	</div>
	<div class="cl pd-5 bg-1 bk-gray mt-20"> 
		<span class="l">
			<a href="javascript:;" class="btn radius" v-on:click="tostat(0)" v-bind:class="[ status==0 ? 'disabled' : 'btn-success']">全部</a> 
			<a href="javascript:;" class="btn radius" v-on:click="tostat(2)" v-bind:class="[ status==2 ? 'disabled' : 'btn-success']">已采集</a> 
			<a href="javascript:;" class="btn radius" v-on:click="tostat(1)" v-bind:class="[ status==1 ? 'disabled' : 'btn-success']">未采集</a>
			<a href="javascript:;" class="btn radius" v-on:click="tostat(-1)" v-bind:class="[ status<0 ? 'disabled' : 'btn-success']">错误</a>
		</span> 
		<span class="r">共有数据：<strong>{{ count }}</strong> 条</span> </div>
	{% endraw %}
	<div class="mt-20">
		<table class="table table-border table-bordered table-bg table-hover table-sort table-responsive">
			<thead>
				<tr class="text-c">
					<th width="25"><input type="checkbox" name="" value=""></th>
					<th>URL</th>
					<th width="80">采集分类</th>
					<th width="80">状态</th>
					<th width="120">操作</th>
				</tr>
			</thead>
			<tbody>
				{% raw %}
             	<tr class="text-c" v-for="i in urllist">
					<td><input type="checkbox" v-bind:value="i.id"  name="ids[]"></td>
					<td><a v-bind:href="i.url" target="_blank" v-bind:title="i.url">{{ i.url }}</a></td>
					<td>{{ i.name }}</td>
					<td>
						<span v-if="i.status==2" class="c-success sts">已采集</span>
						<span v-else-if="i.status==1" class="c-warning sts">未采集</span>
						<span v-else class="c-warning sts">{{ i.status }}</span>
					</td>
					<td class="f-14 td-manage"><a style="text-decoration:none" class="ml-5" onClick="article_del(this,{{ i.id }})" href="javascript:;" title="删除"><i class="Hui-iconfont">&#xe6e2;</i></a></td>
				</tr>			
			</tbody>
		</table>
		<! -- 分页  -->
		<div class="page-bar">
			<ul>
				<li v-if="page>1"><a v-on:click="page--,pageClick()">上一页</a></li>
				<li v-if="page==1"><a class="banclick">上一页</a></li>
				<li v-for="index in pagelist" v-bind:class="{ 'active': page == index}">
				<a v-on:click="btnClick(index)">{{ index }}</a>
				</li>
				<li v-if="page!=all"><a v-on:click="page++,pageClick()">下一页</a></li>
				<li v-if="page == all"><a class="banclick">下一页</a></li>
				<li><a>共<i>{{all}}</i>页</a></li>
			</ul>
		</div>
		{% endraw %}
	</div>
</div>
</div>
<script type="text/javascript">
	var urllist = [
		{% for k,i in data %}
		{ 'id' : {{ i.id }} , 'url': '{{ i.url }}' ,'name': '{{ i.collection.name }}' ,'status': '{{ i.status }}' },
		{% endfor %}
	];
   var vm = new Vue({
      el: '#app',
      data: {
      	colid:{{ colid }},
      	count:{{ count }},
      	page:{{ page }},
        kw:'{{ kw }}',
        urllist:urllist,
        status:{{ status }},
        all:{{ all }},
        pagelist:[]
    	},
    	methods:{
    		update:function(){
    			var that = this;
    			axios.get('/collectionlist?vue=1&colid='+this.colid+'&status='+this.status+'&kw='+this.kw+'&page='+this.page)
    			.then(function(data){
    				that.urllist = data.data.urllist;
    				that.count = data.data.count;
    				that.all = data.data.all;
    				that.setpage();
    			})
    			.catch(function (error) {
				    console.log(error);
				});
				
    		},
    		tostat:function(status){
    			this.page = 1;
    			this.status = status;
    			this.update();
    		},
    		serch:function(){
    			this.page = 1;
    			this.update();
    		},
    		//分页
			btnClick: function(data){
				if(data != this.page){
					this.page = data
				}
				//根据点击页数请求数据
				this.update();
			},
			pageClick: function(){
				//根据点击页数请求数据
				this.update();
			},
			setpage:function(){
				var left = 1;
				var right = this.all;
				var ar = [];
				if (this.page<=5) {
					while (left <= this.page){
						ar.push(left)
						left ++
					}
				}else{
					while (left <= 2){
						ar.push(left)
						left ++
					}
					ar.push('...')
					if (this.page>5) {
						ar.push(this.page-2);
						ar.push(this.page-1);
					}
					ar.push(this.page)
					
				}
				var aftp = this.page+4;
				if (this.all<aftp) {
					for (var i = this.page+1; i <= this.all; i++) {
						ar.push(i)
					}
				}else{
					for (var i = this.page+1; i <= aftp; i++) {
						ar.push(i)
					}
				}
				if ((this.all-this.page)>=5) {
					ar.push('...');
					if ((this.all-this.page)>6) {
						ar.push(this.all-1);
					}
					ar.push(this.all);
				}
				this.pagelist = ar;
			}
    	},
    	mounted: function (){
			this.setpage();
    	}
    });

 
</script>
<!--_footer 作为公共模版分离出去-->
<script type="text/javascript" src="/static/lib/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript" src="/static/lib/layer/2.4/layer.js"></script>
<script type="text/javascript" src="/static/h-ui/js/H-ui.min.js"></script>
<script type="text/javascript" src="/static/h-ui.admin/js/H-ui.admin.js"></script> <!--/_footer 作为公共模版分离出去-->

<!--请在下方写此页面业务相关的脚本-->

<script type="text/javascript">

/*删除*/
// function _del(obj,id){
// 	layer.confirm('确认要删除吗？',function(index){
// 		$.ajax({
// 			type: 'GET',
// 			url: '/article_del?id='+id,
// 			dataType: 'json',
// 			success: function(data){
// 				$(obj).parents("tr").remove();
// 				layer.msg('已删除!',{icon:1,time:1000});
// 			},
// 			error:function(data) {
// 				console.log(data.msg);
// 			},
// 		});
// 	});
// }
/*批量删除*/
function datadel(){
	layer.confirm('确认要删除吗？',function(index){
		var checklist = $("input[name='ids[]']:checked");
		if (checklist.length<=0) {
			layer.msg('请选择要删除的!',{icon:5,time:1000});
			return false;
		}
		var postids = []
		for(var i=0; i<checklist.length;i++){
			postids.push(checklist[i].value);
		}
		var indexx = layer.load(1, {shade: [0.1,'#fff']});
		$.post('/collectionlist_del',{data:JSON.stringify(postids)},function(data){
			layer.close(indexx);
			layer.msg('已删除!',{icon:1,time:1000});
			setTimeout(function(){
		        window.location.reload();
		    },2000);
		})
	})
}

</script>
</body>
</html>